﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefStation" :model="stateStation.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_LineCodeId_FormItem" prop="Entity.LineCodeId" :label="$t('message.autotrans._Model_Station_LineCode')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Station_LineCode')}), trigger: 'blur' }]" >
            <el-select v-model="stateStation.vmModel.Entity.LineCodeId" filterable clearable>
               <el-option v-for="item in stateStation.AllLineCodes" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_StationCode_FormItem" prop="Entity.StationCode" :label="$t('message.autotrans._Model_Station_StationCode')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Station_StationCode')}), trigger: 'blur' }]" >
            <el-input v-model="stateStation.vmModel.Entity.StationCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_StationName_FormItem" prop="Entity.StationName" :label="$t('message.autotrans._Model_Station_StationName')">
            <el-input v-model="stateStation.vmModel.Entity.StationName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Base_Status_FormItem" prop="Entity.Base_Status" :label="$t('message.autotrans._Model_Station_Base_Status')">
            <el-select v-model="stateStation.vmModel.Entity.Base_Status" clearable>
               <el-option key="CREATED" value="CREATED" :label="$t('message.autotrans._Enum_BaseStatus_CREATED')"></el-option>
               <el-option key="USED" value="USED" :label="$t('message.autotrans._Enum_BaseStatus_USED')"></el-option>
               <el-option key="FORBIDDEN" value="FORBIDDEN" :label="$t('message.autotrans._Enum_BaseStatus_FORBIDDEN')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_StationManagerID_FormItem" prop="Entity.StationManagerID" :label="$t('message.autotrans._Model_Station_StationManagerID')">
            <el-input v-model="stateStation.vmModel.Entity.StationManagerID" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_StationManagerName_FormItem" prop="Entity.StationManagerName" :label="$t('message.autotrans._Model_Station_StationManagerName')">
            <el-input v-model="stateStation.vmModel.Entity.StationManagerName" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onSubmitStation"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

        <WtmButton @click="onCloseStation"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageBaseInformationStationCreate;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { stationApi } from '/@/api/baseinformation/station';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefStation = ref();
const stateStation = reactive({
    vmModel: {
	  Entity:{
        LineCodeId: null,
        StationCode: '',
        StationName: '',
        Base_Status: undefined,
        StationManagerID: '',
        StationManagerName: '',
      },

	},
    
    AllLineCodes: [] as any[],
});

// 取消
const onCloseStation = () => {
    closeDialog();
};

// 提交
const onSubmitStation = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefStation.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            stationApi().add(stateStation.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
	})
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/BaseInformation/Station/GetLines',[],false).then(x=>{stateStation.AllLineCodes = x});
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

